#pragma once
# include <vector>
# include <string>
# include "dxgi1_2.h"
# include <wrl/client.h>


# define CREAT_DXGIFACTORY_ERROR 301
# define DXGI_FACTORY_NOT_FOUND 302
# define FACTORY_FAILD 303
# define ADAPTER_FAILD 304
# define OUTPUT_NOT_FOUND 305
# define OUTPUT_FAILD 306

struct IUnknown;
struct IDXGIAdapter1;
struct IDXGIOutput1;
struct ID3D11Device;
struct ID3D11DeviceContext;
struct ID3D11Texture2D;
struct IDXGIOutputDuplication;

class _declspec(dllimport) VideoCapture {
public:
	VideoCapture(IDXGIAdapter1* _adapter, IDXGIOutput1* _output);
	bool capture();
	int width() const;
	int height() const;
	ID3D11Texture2D* getImageTexture() const;
	ID3D11Device* getDevice() const;
	ID3D11DeviceContext* getContext() const;
	~VideoCapture();

	static int enumCaptureToVector(std::vector<VideoCapture*>*& _videoCaptureVector);

	static void releaseCaputreFromVector(std::vector<VideoCapture*>* _videoCaptureVector);
private:
	Microsoft::WRL::ComPtr<IDXGIAdapter1> m_adapter = nullptr;
	Microsoft::WRL::ComPtr<ID3D11Device> m_device = nullptr;
	Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_context = nullptr;
	Microsoft::WRL::ComPtr<ID3D11Texture2D> m_image = nullptr;
	Microsoft::WRL::ComPtr<IDXGIOutputDuplication> m_duplication = nullptr;

	int m_width = 0;
	int m_height = 0;
};
